<div ng-controller="contractListCtrl">
    <div class="table-header mt5 clearfix ng-scope">
        <span class="fl lh30 f14">合同管理</span>
    </div>
    <my-nav data-nav-items="filterBusinessType" onchanged="changeBusinessType" data-title="业务类型:"
            data-text-field="business_type_name"></my-nav>
    <my-nav data-nav-items="filterDataStatus" onchanged="changeStatus" data-title="合同状态:"></my-nav>
    <my-nav data-nav-items="filterDataNature" onchanged="changeNature" data-title="合同性质:"
            data-text-field="property_name"></my-nav>
    <my-nav data-nav-items="filterDataCities" onchanged="changeCity" data-title="城市区域:" data-text-field="areaName"
            need-more="true"></my-nav>
    <my-nav data-nav-items="filterISOver" onchanged="changeOver" data-title="是否完结:"></my-nav>

    <my-nav data-nav-items="filterDataInvoiceTypes" onchanged="changeInvoiceType" data-title="发票类型:"></my-nav>

    <div class="section-table mt20">
        <div class="table-header lh30 pb5 clearfix">
            <span class="fl lh30 f14">合同列表</span>

            <div class="fr btn-group" ng-init="downloadUrl=''">
                <span class="fl">录入时间：</span>
                <input type="text" class="fl input-text w120 ml3 input-date" ng-model="query.beginInputDate"
                       ng-enter="query.execute()" ui-date format="yyyy-MM-dd">
                <span class="fl ml3">-</span>
                <input type="text" class="fl input-text w120 ml3 input-date" ng-model="query.endInputDate"
                       ng-enter="query.execute()" ui-date format="yyyy-MM-dd">

                <input class="input-text fl ng-pristine ng-untouched ng-valid ml3" style="width: 300px;" type="text"
                       placeholder="公司/合同编号/客户全称" ng-model="query.keyword" ng-enter="query.execute()"/>
                <a class="btn" href="javascript: void(0)" ng-click="query.execute()">查询</a>

                <!--<a class="btn" href="/contract/edit.shtml#base" target="_blank">新建合同</a>-->
	            <!-- ng-change 这里监测的是 ng-model里面的 type_name -->
	            <select style="width: 100px;" class="btn" name="" id="create_contract" ng-model="type_name" ng-options="type_name for type_name in contractType"
	                    ng-change="redirctToCreate(type_name)">
		            <!--<option id="default_option" value="" class="11">新建合同</option>-->
	            </select>

                <!--<a class="btn btn-yellow" href="javascript: void(0)" ng-click="export()">导出合同excel</a>-->

                <select style="width: 100px;" class="btn" name="" id="export_data" ng-model="export_type" ng-options="export_type for export_type in exportType"
                        ng-change="redirctToExport(export_type)">
                </select>
            </div>
        </div>
        <div class="table-header">
            <div class="table-header lh30 pb5 clearfix">
                <div class="fr btn-group" ng-init="downloadUrl=''">
                    <a href="javascript:;" class="btn btn-yellow" ui-dialog="导入纸质合同" ui-dialog-data="{}" ui-dialog-show="onExportPaperContractEditShow($dialog, $dialogScope)" ui-dialog-cache="false" ui-dialog-url="/contract/dialog/paper-contract-export.html">
                        导入纸质合同
                    </a>
                </div>
            </div>
        </div>

        <div id="grid" class="table-wrap mt10">
            <table width="100%" class="valign-t">
                <thead>
                <tr>
                    <th width="35">序号</th>
                    <th width="150">客户信息</th>
                    <th width="190">合同信息</th>
                    <th>合同签署公司</th>
                    <th width="140">签约信息</th>
                    <th width="120">金额信息</th>
                    <th width="65">合同状态</th>
                    <th width="90">操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="record in contracts">
                    <td height="40"><p ng-bind="$index + 1 + startPageIndex"></p></td>
                    <td class="lh14">
                        <p ng-if="[1,2].indexOf(record.business_type_code)>=0" ng-bind="record.customer_full_name"></p>
                        <p class="c-gray" ng-if="[1,2].indexOf(record.business_type_code)>=0">客户简称:{{record.customer_name}}</p>

                        <p ng-if="[3,4,5,6].indexOf(record.business_type_code)>=0" ng-bind="record.supplier_name"></p>

                        <!--<p ng-if="[5].indexOf(record.business_type_code)>=0" ng-bind="record.customer_name"></p>-->

                        <p ng-if="record.business_type_code==7" ng-bind="record.activity_name"></p>
                    </td>
                    <td>
                        <a ng-href="/contract/edit.shtml#/base?id={{record.contract_id}}&contractType={{record.business_type_name}}" target="_blank" class="clearfix"
                           title="编辑合同信息"><p
                                ng-bind="record.contract_code"></p></a>

                        <p class="c-gray">合同性质:{{record.property_name}}</p>

                        <p ng-if="record.beginOn" class="c-gray">
                            租期:{{record.beginOn|strdate:'yyyy-MM-dd'}}至{{record.endOn|strdate:'yyyy-MM-dd'}}
                        </p>
                    </td>
                    <td>
                        <p ng-bind="record.company_name"></p>

                        <p class="c-gray" ng-if="[4,5,6].indexOf(record.business_type_code)==-1">所属区域:{{record.area_name}}</p>

                        <p class="c-gray" ng-if="record.business_type_code==5">所属区域:{{record.link_areaname}}</p>
                    </td>
                    <td>
                        <p ng-if="[5,6,7].indexOf(record.business_type_code)==-1">签约人:{{record.user_name}}</p>

                        <p ng-if="[5].indexOf(record.business_type_code)>=0">签约人:{{record.link_user_name}}</p>

                        <p class="c-gray" ng-if="record.business_type_code!=7">签约日期:{{record.sign_date | strdate: 'yyyy-MM-dd'}}</p>

                        <p class="c-gray">录入日期:{{record.input_date | strdate: 'yyyy-MM-dd'}}</p>
                    </td>
                    <td>
                        <p>签约金额:{{record.sign_amount | number}}</p>

                        <p class="c-gray" ng-if="record.business_type_code==1">租用金额:{{record.rent_amount | number}}</p>

                        <p class="c-gray" ng-if="[1,5].indexOf(record.business_type_code)>=0">已结算金额:{{record.balance_amount | number}}</p>

                        <p class="c-gray">已回款金额:{{record.received_amount | number}}</p>
                    </td>
                    <td>
                        <p ng-if="record.contract_status == 0 && record.is_cancelled == 0">草稿</p>

                        <p ng-if="record.contract_status == 1 && record.is_cancelled == 0">提交复核</p>

                        <p ng-if="record.contract_status == 2 && record.is_cancelled == 0">已审核</p>

                        <p ng-if="record.is_cancelled == 1">作废</p>

                        <p ng-if="record.isover==1 && record.contract_status==2">已完结</p>

                        <p ng-if="record.isover==0 && record.contract_status==2">未完结</p>
                    </td>
                    <td>
                        <div row-toolbar min-buttons-show="8">
                            <a ng-click="submitVerify(record)" class="clearfix" href="javascript:void(0)"
                               ng-if="record.contract_status==0 && record.is_cancelled == 0"
                               title="提交复核">提交复核</a>
                            <a ng-click="cancelVerify(record)" class="clearfix" href="javascript:void(0)"
                               ng-if="record.contract_status==1 && record.is_cancelled == 0"
                               title="撤销复核">撤销复核</a>
                            <a ng-click="confirmVerify(record)" class="clearfix" href="javascript:void(0)"
                               ng-if="record.contract_status==1 && record.is_cancelled == 0"
                               title="复核">复核</a>
                            <a ng-click="cancelConfirmVerify(record)" class="clearfix" href="javascript:void(0)"
                               ng-if="record.contract_status==2 && record.is_cancelled == 0"
                               title="复核">取消审核</a>
                            <a ng-href="/contract/edit.shtml#/base?id={{record.contract_id}}&contractType={{record.business_type_name}}" target="_blank"
                               class="clearfix" title="编辑合同信息"
                               ng-if="record.contract_status == 0 && record.is_cancelled == 0"
                               title="编辑">编辑</a>
                            <a ng-href="/contract/edit.shtml#/base?id={{record.contract_id}}&contractType={{record.business_type_name}}" target="_blank"
                               class="clearfix" title="编辑发票、回款信息"
                               ng-if="record.contract_status!=0 || record.is_cancelled == 1"
                            >编辑</a>
                            <a ng-click="cancelContract(record)" class="clearfix" href="javascript:void(0)"
                               ng-if="record.is_cancelled == 0"
                               title="作废">作废</a>
                            <a ng-click="setOverContract(record,1)" class="clearfix" ng-href="javascript:void(0)"
                               class="clearfix"
                               ng-if="record.isover==0 && record.contract_status==2"
                               title="设置为完结">完结</a>
                            <a ng-click="setOverContract(record,0)" class="clearfix" ng-href="javascript:void(0)"
                               class="clearfix"
                               ng-if="record.isover==1 && record.contract_status==2"
                               title="设置为未完结">未完结</a>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="no-data" style="display:none"><span>暂无数据</span></div>
        </div>
        <div id="pagination" class="pagination"></div>
    </div>
</div>
